<?php # Script 8.6 - view_users02.php
// This script retrieves all the records from the users table.

$page_title = '사용자 목록';
include('includes/header.html');
?>
	<div id="wrap">
		<div class="navbar navbar-inverse">
			<div class="navbar-inner">
				<div class="container">
					<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</a>
					<a class="brand" href="index.php">User Manager</a>
					<div class="nav-collapse collapse">
						<ul class="nav">
							<li class=""><a href="index.php">홈</a></li>
							<li class=""><a href="register02.php">사용자 등록</a></li>
							<li class="active"><a href="view_users02.php">사용자 목록</a></li>
							<li class=""><a href="password.php">비밀번호 변경</a></li>
							<li class=""><a href="#">link five</a></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="container">
			<div class="page-header">
    	<!-- Start of the page-specific content. -->
<?php

// Page header:
echo '<h1>Registered Users</h1>';

require_once('./mysqli_connect.php'); // Connect to the db.

// Make the query:
$q = "select concat(last_name, ', ', first_name) as name, date_format(registration_date, '%Y-%m-%d') as dr from users order by registration_date asc";
$r = @mysqli_query($dbc, $q); // Run the query.

// Count the number of returned rows:
$num = mysqli_num_rows($r);

if ($num > 0) { // If it ran OK, display the records.

	// Print how many users there are:
	echo "<p>There are currently $num registered users.</p>\n";

	// Table header.
	echo '<table class="table table-striped table-bordered table-hover table-condensed">
			<thead>
	            <tr>
	                <th>Name</th>
	                <th>Date Registered</th>
	            </tr>
	        </thead>
	        <tbody>';
	
	// Fetch and print all the records:
	while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
		echo '<tr>
                <td>'.$row['name'].'</td>
                <td>'.$row['dr'].'</td>
            </tr>';
	}
        
    echo '</tbody>
    	</table>'; // Close the table.

   	mysqli_free_result($r); // Free up the resources.
            
} else { // If no records were returned.

	echo '<p class="text-error">There are currently no registered users.</p>';

} // End of if ($r) IF.

mysqli_close($dbc); // Close the database connection.

?>
<?php
include('includes/footer.html');
?>